package com.tiger.log.api;

import com.tiger.log.common.response.Response;
import com.tiger.log.server.service.SysAuthLogService;
import org.springframework.context.annotation.Description;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName AuthController
 * @Description TODO
 * @Author huxuehao
 **/
@RestController
@RequestMapping("/log/auth")
public class AuthController {

    private final SysAuthLogService sysAuthLogService;

    public AuthController(SysAuthLogService sysAuthLogService) {
        this.sysAuthLogService = sysAuthLogService;
    }

    @GetMapping("/get-all")
    @Description("获取所有的记录")
    public Response getAll() {
        return Response.success(sysAuthLogService.getAll());
    }


    @GetMapping("/get-by-id")
    @Description("根据Id获取记录")
    public Response getById(@RequestParam String id) {
        return Response.success(sysAuthLogService.getById(id));
    }


    @GetMapping("/get-by-userCode")
    @Description("获取所有的记录")
    public Response getByUserCode(@RequestParam String userCode) {
        return Response.success(sysAuthLogService.getByUserCode(userCode));
    }


    @GetMapping("/delete-all")
    @Description("删除所有记录")
    public Response deleteAll() {
        return Response.success(sysAuthLogService.deleteAll());
    }


    @GetMapping("/delete-by-ids")
    @Description("根据id删除记录")
    public Response deleteByIds(@RequestParam List<String> ids) {
        return Response.success(sysAuthLogService.deleteByIds(ids));
    }


    @GetMapping("/delete-by-userCodes")
    @Description("获取所有的记录")
    public Response deleteByUserCodes(@RequestParam List<String> userCodes) {
        return Response.success(sysAuthLogService.deleteByUserCodes(userCodes));
    }

}
